<%-- 
    Document   : viewUsers
    Created on : Apr 10, 2011, 8:30:15 PM
    Author     : Nguyen Hung
--%>
<%@page import="Model.DAO"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@include file="../WEB-INF/jspf/headeradmin.jspf" %>
       
        
        <style type="text/css" title="currentStyle">
            @import "datatable/demo_page.css";
            @import "datatable/demo_table_jui.css";
            @import "datatable/jquery-ui-1.8.4.custom.css";
        </style>
        <script type="text/javascript" language="javascript" src="datatable/jquery.js"></script>
        <script type="text/javascript" language="javascript" src="datatable/jquery.dataTables.js"></script>
		<script type="text/javascript">
             function xacnhan()
			 {
	     return confirm('Bạn thực sự muốn xóa Người dùng này?');
			}
    </script>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                oTable = $('#userTable').dataTable({
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers"
                });
            } );
        </script>
		
  
      
        <%
                    Connection connection = DAO.getConnection();
                    String sql = "select * from user";
                    PreparedStatement preparedStatement = connection.prepareStatement(sql);
                    ResultSet rs = preparedStatement.executeQuery();


        %>
        <a href="addUser.jsp">Thêm User</a>&nbsp; &nbsp;
        <a href="editUsers.jsp">Sửa User</a>
        <table width="525" border="1" class="display" id="userTable">
            <thead>
            <th>Số Thứ Tự</th>
            <th>Username</th>
            <th>Họ và Tên</th>
            <th>Role</th>
            <th>Xóa</th>
        </thead>
        <tbody>
            <%
                        int i = 0;
                        while (rs.next()) {
                            i++;
            %>
            <tr class="gradeC">
                <td><%=i + ""%></td>
                <td><%=rs.getString("username")%></td>
                <td><%=rs.getString("fullname")%></td>
                <td><%=rs.getString("role")%></td>
                <td>
                    <!--<form action="DeleteUser" >
                        <input type="hidden" value = "<%=rs.getString("username")%>"/>
                        <input type = "submit" name = "submit" value = "Xóa"/>
                    </form>-->
                    <a href="DeleteUser?username=<%=rs.getString("username")%>" onclick="return xacnhan()">Xóa</a>
                </td>

            </tr>
            <%
                }
            %>
        </tbody>
    </table>
<%@include file="../WEB-INF/jspf/footeradmin.jspf" %>